/*

	Paper tables
		Makes the tables for the "Improving Early Literacy through Teacher Professional Development: Experimental Evidence from Colombia" paper

*/


clear
set more off
version 15.1

//set directory
if "`c(username)'"=="juuli"  {
	global dir =  "C:\Users\juuli\Dropbox\PaperPrimeroManizales\6.Text\Submissions\JPubE\Harvard Dataverse/" 		
	}

	
run "$dir/insertrow.ado"
run "$dir/swaprows.ado"
include "$dir/specchartManizales.do"

/*
capture ssc install texsave
capture ssc install outreg2
capture ssc install moremata
*/

********************************************************************************
///TABLE 1

 use "$dir/datawide.dta", clear
 
 //estimation
	 //school-level vars
	 global balance_schools "rural_school schoolsize avg_classsize nclass allliter_prcsq allmath_prcsq" 
	 local V1: word count $balance_schools
	 matrix P1 = J(`V1',1,.)
	 tabstat $balance_schools if n_school==1, by(T) format(%9.2f) notot save
	 matrix R1 = r(Stat2)',r(Stat1)'
	 tabstat $balance_schools if n_school==1 , statistics(N) format(%9.2f) save
	 matrix N1 = r(StatTotal)'    
	 local v = 1
	 foreach var in $balance_schools{
		ereturn clear
		capture areg `var' T if n_school==1, a(block) cluster(schoolid)
		if _rc==0 matrix P1[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		local ++v
	 }

	 // student-level vars
	 global balance_students1 "age female nodisab VlowSES" 
	 local V2: word count $balance_students1
	 matrix P2= J(`V2',1,.)
	   tabstat $balance_students1, by(T) format(%9.2f) notot save
	   matrix R2 = r(Stat2)',r(Stat1)'
	   tabstat $balance_students1 , statistics(N) format(%9.2f) save
	   matrix N2 = r(StatTotal)'   
	   local v = 1
	   foreach var in $balance_students1{
		 ereturn clear
		 capture areg `var' T , a(block) cluster(schoolid)
		 if _rc==0 matrix P2[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		 local ++v
	   }

	 global balance_students2 "predic_data literacy_index motora_index socioafectiva_index" 
	 local V3: word count $balance_students2
	 matrix P3= J(`V3',1,.)
	   tabstat $balance_students2, by(T) format(%9.2f) notot save
	   matrix R3 = r(Stat2)',r(Stat1)'
	   tabstat $balance_students2, statistics(N) format(%9.2f) save
	   matrix N3 = r(StatTotal)'   
	   //pvalues
	   local v = 1
	   foreach var in $balance_students2{
		 ereturn clear
		 capture areg `var' T , a(block) cluster(schoolid)
		 if _rc==0 matrix P3[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		 local ++v
	   }

	 global balance_attrition "attrition_e attrition_m attrition_f attrition_m2" 
	 local V4: word count $balance_attrition
	 matrix P4= J(`V4',1,.)
     tabstat $balance_attrition, by(T) format(%9.2f) notot save
     matrix R4 = r(Stat2)',r(Stat1)'
     tabstat $balance_attrition, statistics(N) format(%9.2f) save
     matrix N4 = r(StatTotal)'   
     local v = 1
     foreach var in $balance_attrition{
		ereturn clear
		capture areg `var' T , a(block) cluster(schoolid)
		if _rc==0 matrix P4[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		local ++v
   }

 //compilation
 matrix T1 = R1,P1[1...,1], N1
 matrix T2 = R2,P2[1...,1], N2
 matrix T3 = R3,P3[1...,1], N3
 matrix T4 = R4,P4[1...,1], N4
 
 matrix T=T1\T2\T3\T4
 mat list T
 drop _all
 svmat2 T, rnames(var) 

 insertrow, place(before) row(1)
 insertrow, place(before) row(8)
 insertrow, place(before) row(13)
 insertrow, place(before) row(18)

 gen Panel = "" 
 gen Variables=""
 order Panel Variables
 replace Panel = "Panel A:" in 1
 replace Panel = "Panel B:" in 8
 replace Panel = "Panel C:" in 13
 replace Panel = "Panel D:" in 18
  
 replace Variables="Avg. schools' characteristics" if _n==1
 replace Variables="\hspace{2mm} Rural school" if _n==2
 replace Variables="\hspace{2mm} School size" if _n==3 
 replace Variables="\hspace{2mm} Class size" if _n==4
 replace Variables="\hspace{2mm} Number of classrooms in Grade 1" if _n==5
 replace Variables="\hspace{2mm} Literacy" if _n==6
 replace Variables="\hspace{2mm} Math score" if _n==7
 
 replace Variables="Avg. beg. G1 students' characteristics" if _n==8
 replace Variables="\hspace{2mm} Age" if _n==9
 replace Variables="\hspace{2mm} Female" if _n==10
 replace Variables="\hspace{2mm} No disability" if _n==11 
 replace Variables="\hspace{2mm} Low socio-econ status" if _n==12 

 replace Variables="Avg. end KG students' characteristics" if _n==13
 replace Variables="\hspace{2mm} Prob. response" if _n==14
 replace Variables="\hspace{2mm} Literacy" if _n==15
 replace Variables="\hspace{2mm} Motor" if _n==16
 replace Variables="\hspace{2mm} Socio-affective" if _n==17

 replace Variables="Attrition" if _n==18
 replace Variables="End Grade 1" if _n==19
 replace Variables="Beg. Grade 2" if _n==20
 replace Variables="End Grade 2" if _n==21
 replace Variables="Beg. Grade 3" if _n==22
 drop var
 
 insertrow, place(before) row(18)
 insertrow, place(before) row(13)
 insertrow, place(before) row(8)
 insertrow, place(before) row(1)

 foreach j in 1 2 3{
   gen aux = string(T`j', "%9.2f")
   replace aux = "" if aux=="."
   drop T`j'
   ren aux T`j'
 }
 
 foreach j in 4{
   gen aux = string(T`j', "%9.0f")
   replace aux = "" if aux=="."
   drop T`j'
   ren aux T`j'
 }
 order Panel Variables T1 T2 T3 T4 
 
 foreach var of varlist T2 {
	replace `var'="0.00" if `var'=="-0.00" | `var'=="-0.01" 
 }
 label var T1 "Treatment"
 label var T2 "Control"
 label var T3 "p-value of $H0:\beta_t=\beta_c$"
 label var T4 "Obs."
 
 #delimit ;
 global note "Note: Panel A shows the average school-level characteristics. Literacy and math scores are expressed as average proportion of correct answers in each subtask. They are averages of school-year averages (3rd and 4th grades in years 2015-2018). Panel B shows the average beginning of first grade characteristics of eligible students. Panel C shows the average end of kindergarten characteristics of eligible students and the probability of response for these data. Literacy, motor and socio-affective characteristics are simple averages of indicator sub-itmes that compose each variable. We then standardized to the mean and standard deviation of the  control group. Panel D shows the attrition rates at different time horizons of the eligible students observed at baseline. Columns labeled 'Treatment' show the average for students in schools randomized to treatment. Columns labeled 'Control' show the average for students in schools randomized to control. Column labeled 'p-value of $H0:\beta_t=\beta_c$' presents the p-value of the treatment indicator coefficient in a regression with each row variable as the outcome. All regressions include strata fixed effects and standard errors are clustered at the school level.";
 #delimit cr
 texsave using "$dir/results/Table_Balance.tex", width(0.9\textwidth) frag ///
 replace size(scriptsize) align(llCCCC) location(ht) varlabels rowsep(1ex) ///
 title(Balance and Attrition) marker(tab:balance) ///
 footnote("$note", size(scriptsize)) nofix
 



 *******************************************************************************
 //TABLE 2: 
  //AND ESTIMATES FOR FIGURE 1
 
 /*In the paper version of this table we report non-std control mean and sd at end of grade 1. We do not include in these variables here. We are doing this because publishing the microdata on non-standardized scores could lead to violations of confidentiality of students, teachers or schools.  We computed aggregate statistics fro control and treatment group and are available in file 'scorestabs.dta'.  */

 
 use if cohort==1 using "$dir/datalong.dta", clear
  
 //estimation
 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
 local j = 1
 global out_lang = "sounds nonsense reading readcomp allliter"
 global out_math ="addition subtraction comparison missing equations allmath"
 


 foreach var in $out_lang {
  if `j'==1 local rep = "replace"
  if `j'>1  local rep = ""
  //estimation pooled
	areg `var'_std_ T i.date, a(block) cluster(schoolid)
	outreg2 using "$dir/results/itt_pooled.xml",`rep' keep(T) $outregoptions nocons 	
	specchart  T,spec(main strata cohort1) replace save("$dir/results/`var'_estimates") 

   //estimation by date
	areg `var'_std_ T_date_2 T_date_3 T_date_4 T_date_5 i.date, a(block) cluster(schoolid)
	local N = e(N)
	test T_date_2=T_date_3
	local p1 = string(`r(p)',"%9.3f")	

	test T_date_2=T_date_4
	local p2 = string(`r(p)',"%9.3f")	
	
	test T_date_2=T_date_5
	local p3 = string(`r(p)',"%9.3f")	
	
	outreg2 using "$dir/results/itt.xml",`rep' keep(T_date_2 T_date_3 T_date_4 T_date_5) $outregoptions nocons addstat("Observations", `N' ) addtext("p-value Beg. G2 $<=$ End G1", `p1',"p-value End G2 $<=$ End G1", `p2', "p-value Beg. G3 $<=$ End G1", `p3')

	local j = `j'+1

 }
 
 
 
 //compile 
 use "$dir/results/itt_pooled_dta.dta",clear 
 append using "$dir/results/itt_dta.dta"

 drop if (_n==2 | _n==7 | _n==8)


 insertrow, place(before) row(3)
 
 replace v1="Panel A: Pooled" if _n==3
 replace v1="Panel B: By time horizon" if _n==7
 
 label var v2 "Knowledge of letter sounds"
 label var v3 "Reading of non-words"
 label var v4 "Fluency of oral reading"
 label var v5 "Reading comprehension"
 label var v6 "Literacy score"
 
 replace v1="T x End G1" if v1=="T_date_2"
 replace v1="T x Beg. G2" if v1=="T_date_3"
 replace v1="T x End G2" if v1=="T_date_4"
 replace v1="T x Beg. G3" if v1=="T_date_5"
	
 global note1 "Note: Panel A shows the results the results of estimating equation (\ref{eq:1}) for each column outcome. Each column shows the coefficients \(\theta_{h}\) of equation (\ref{eq:1}), that is, the estimated treatment effects for all time horizons. Panel B shows the results the results of estimating equation (\ref{eq:2}) for each column outcome. Each column shows the coefficients \(\theta_{h}\) of equation (\ref{eq:2}), that is, the estimated treatment effects at different time horizons for each outcome of interest. The rows labeled ``p-value End G2 $<=$ End G1'' and ``p-value Beg. G3 $<=$ End G1'' show the p-value of a test \(H_0:\theta_{2}<=\theta_{1}\) and  \(H_0:\theta_{3}<=\theta_{1}\), respectively. Control mean and S.D. correspond to the number of correct answers. All models include strata and date fixed effects. Standard errors, shown in squared brackets, are clustered at the school level (the unit of randomization). * significant at 10\%; ** significant at 5\%; *** significant at 1\%."
 texsave using "$dir/results/Table_MainOuts_c1.tex", width(\textwidth) ///
 replace size(scriptsize) align(lCCCCC) location(ht) varlabels frag ///
 title(Treatment Effects on Literacy) marker(tab:results) ///
 footnote("$note1", size(scriptsize)) nofix
   
 erase "$dir/results/itt.txt"
 cap erase "$dir/results/itt.xml"
 cap erase "$dir/results/itt_dta.dta"
 erase "$dir/results/itt_pooled.txt"
 cap erase "$dir/results/itt_pooled.xml"
 cap erase "$dir/results/itt_pooled_dta.dta" 
 
 
 *******************************************************************************
 //FIGURE 1
	// ROBUSTNESS. STRATA x DATE FE ESTIMATIONS
	 use if cohort==1 using "$dir/datalong.dta", clear
	  
	  egen block_date=group(block date)
	 //estimation
	 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
	 local j = 1
	 global out_lang = "sounds nonsense reading readcomp allliter"
	 foreach var in $out_lang {
	  if `j'==1 local rep = "replace"
	  if `j'>1  local rep = ""

	  //estimation pooled
		areg `var'_std_ T i.date, a(block_date) cluster(schoolid)
		specchart  T,spec(strata_date cohort1) save("$dir/results/`var'_estimates")

	 }
	 


	// ROBUSTNESS. END-OF-KINDERGARTEN CONTROLS 
	 use if cohort==1 using "$dir/datalong.dta", clear
	  
	 //estimation
	 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
	 local j = 1
	 global out_lang = "sounds nonsense reading readcomp allliter"
	 foreach var in $out_lang {
	  if `j'==1 local rep = "replace"
	  if `j'>1  local rep = ""
	  
		areg `var'_std_ T literacy_index motora_index socioafectiva_index i.date if date>0, a(block) cluster(schoolid)
		specchart  T,spec(strata cohort1 kg_controls) save("$dir/results/`var'_estimates")

	}
	
	
	// LEE-BOUNDS
 
	use if T!=. using "$dir/datalong.dta", clear

	//estimation
	 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
	 local j = 1
	 global out_lang = "sounds nonsense reading readcomp allliter"


	 local j=1
	 foreach var in $out_lang{
		leebounds `var'_std_ T, tight(block) 
		specchart  T, spec(strata cohort1 lee_lowerbound) lee_lowerbound save("$dir/results/`var'_estimates")

		local j=`j'+1
	 }
	 
	 //ITT FOR COHORT 2, END OF GRADE 1
	 		
	 use if cohort==2 using "$dir/datalong.dta", clear
	  
	 //estimation
	 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
	 local j = 1
	 global out_lang = "sounds nonsense reading readcomp allliter"

	 foreach var in $out_lang {

	 //estimation EG1 
	  areg `var'_std_ T i.date if date==1, a(block) cluster(schoolid)
	  specchart  T,spec(strata cohort2)  save("$dir/results/`var'_estimates") 

	 }
	 
  
 // FIGURE ROBUSTNESS
 include "$dir/fig_robustnessManizales_ByOut.do"

 
 *******************************************************************************
 //TABLE 3
 use if cohort==1 using "$dir/datalong.dta", clear
  
 //estimation
 global outregoptions = "dec(3) bracket excel nor2 noobs nonotes dta slow(2000)"
 local j = 1
 global out_math ="addition subtraction comparison missing equations allmath"

 foreach var in $out_math {
  if `j'==1 local rep = "replace"
  if `j'>1  local rep = ""

  //estimation pooled
	areg `var'_std_ T i.date, a(block) cluster(schoolid)
	outreg2 using "$dir/results/itt_pooled.xml",`rep' keep(T) $outregoptions nocons 	
 
  //estimation by date
	areg `var'_std_ T_date_2 T_date_3 T_date_4 T_date_5 i.date , a(block) cluster(schoolid)
	local N = e(N)

  outreg2 using "$dir/results/itt.xml",`rep' keep(T_date_2 T_date_3 T_date_4 T_date_5) $outregoptions nocons addstat("Observations", `N' ) 

  local j = `j'+1
 }
 
 //compile
 use "$dir/results/itt_pooled_dta.dta",clear
 append using "$dir/results/itt_dta.dta"

  drop if (_n==2 | _n==7 | _n==8)

 insertrow, place(before) row(3)
 

 replace v1="Panel A: Pooled" if _n==3
 replace v1="Panel B: By time horizon" if _n==7
 
 label var v2 "Additions"
 label var v3 "Subtractions"
 label var v4 "Comparing numbers" 
 label var v5 "Ordering numbers"
 label var v6 "Equations"
 label var v7 "Math score"
 
 replace v1="T x End G1" if v1=="T_date_2"
 replace v1="T x Beg. G2" if v1=="T_date_3"
 replace v1="T x End G2" if v1=="T_date_4"
 replace v1="T x Beg. G3" if v1=="T_date_5"

 global note1 "Note: All models include cohort and strata fixed effects. Standard errors, shown in squared brackets, are clustered at the school level (the unit of randomization). The outcome scores were standardized with respect to eligible control students of respective year. * significant at 10\%; ** significant at 5\%; *** significant at 1\%."
 texsave using "$dir/results/Table_OtherOuts_c1.tex", width(\textwidth) ///
 replace size(scriptsize) align(lCCCCCC) location(ht) varlabels frag ///
 title(Treatment Effects on Other Outcomes) marker(tab:otherouts1) ///
 footnote("$note1", size(scriptsize)) nofix

 erase "$dir/results/itt.txt"
 cap erase "$dir/results/itt.xml"
 cap erase "$dir/results/itt_dta.dta"
 erase "$dir/results/itt_pooled.txt"
 cap erase "$dir/results/itt_pooled.xml"
 cap erase "$dir/results/itt_pooled_dta.dta" 
 
 
 
  


********************************************************************************
 //TABLE 4

 use if cohort==1 using "$dir/datalong.dta", clear 

 // new vars  
 foreach het in  female VlowSES literacy_index  peers_sd class_size{
   cap gen T`het'=T*`het'
   
   global outregoptions = "dec(3) bracket excel nor2 nonotes dta slow(2000)"
   global out_lang = "sounds nonsense reading readcomp allliter"
   local j=1
   foreach var in $out_lang {
	   if `j'==1 local rep = "replace"
	   if `j'>1  local rep = ""
		   
	   areg `var'_std_ T T`het' `het'  i.date, absorb(block) cluster(schoolid)
	   test T+T`het'=0		
	   local p=string(`r(p)',"%9.3f")
	   outreg2 using "$dir/results/T_`het'.xml", `rep'  keep(T T`het') $outregoptions nocons addtext("p-value T+Tx`het'=0", `p')  
	   
	   local j=`j'+1
   } 
 }
 
 //compile
 use "$dir/results/T_female_dta.dta", clear
 foreach het in VlowSES literacy_index {  
   append using "$dir/results/T_`het'_dta.dta"
 }
 append using "$dir/results/T_peers_sd_dta.dta"  
 append using "$dir/results/T_class_size_dta.dta"

 
 drop if (_n==2 | _n==8 | _n==11 | _n==12 | _n==18 | _n==21 | _n==22 | _n==28 | _n==31 | _n==32 | _n==38 | _n==41 | _n==42 | _n==48)
 
 replace v1 = "T x girl" if v1=="Tfemale"
 replace v1 = "T x low socio-econ. status" if v1=="TVlowSES"
 replace v1 = "T x literacy index" if v1=="Tliteracy_index"
 replace v1 = "T x baseline score SD " if v1=="Tpeers_sd"
 replace v1 = "T x class size" if v1=="Tclass_size"
 
 replace v1 = "p-value of sum of coeffs." if v1=="p-value T+Tx homogeneous classroom=0"
 
 insobs 1, b(24)
 insobs 1, b(3)
 
 replace v1 = "Panel A: Student-level variables" in 3
 replace v1 = "Panel B: Classroom-level variables" in 25
 
 label var v2 "Knowledge of letter sounds"
 label var v3 "Reading of non-words"
 label var v4 "Fluency of oral reading"
 label var v5 "Reading comprehension"
 label var v6 "Literacy score" 
 
 
 global note1 "Note: Each panel shows estimates of treatment coefficient of equation (1) and the interaction between treatment and the heterogeneity variable. All models include the heterogeneity variable as a control, date, and strata fixed effects. Standard errors, shown in squared brackets, are clustered at the school-level (the unit of randomization).  * significant at 10\%; **significant at 5\%; *** significant at 1\%."
 
 texsave using "$dir/results/Appendix_Table_Heterogeneity_c1.tex", width(\textwidth) ///
 replace size(scriptsize) align(lCCCCC) location(ht) varlabels frag ///
 title(Treatment Effect Heterogeneity) marker(tab:heterogeneity_all) ///
 footnote("$note1", size(scriptsize)) nofix


 
 



 
 ******************************************************************************** 
 /// APPENDIX TABLE 1
 use "$dir/datawide.dta", clear
 
 
 //sample 
 global sample "if (attrited==0)" 
 

 //estimation
	 // student-level vars
	 global balance_students1 "age female nodisab VlowSES" 
	 local V2: word count $balance_students1
	 matrix P2= J(`V2',1,.)
	   tabstat $balance_students1 $sample , by(T) format(%9.2f) notot save //sample_simat==1 &
	   matrix R2 = r(Stat2)',r(Stat1)'
	   tabstat $balance_students1 $sample, statistics(N) format(%9.2f) save //sample_simat==1 &
	   matrix N2 = r(StatTotal)'   
	   local v = 1
	   foreach var in $balance_students1{
		 ereturn clear
		 capture areg `var' T $sample, a(block) cluster(schoolid) //sample_simat==1 &
		 if _rc==0 matrix P2[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		 local ++v
	   }

	 global balance_students2 "predic_data literacy_index motora_index socioafectiva_index" 
	 local V3: word count $balance_students2
	 matrix P3= J(`V3',1,.)
	   tabstat $balance_students2 $sample, by(T) format(%9.2f) notot save //sample_simat==1 &
	   matrix R3 = r(Stat2)',r(Stat1)'
	   tabstat $balance_students2 $sample, statistics(N) format(%9.2f) save //sample_simat==1 & 
	   matrix N3 = r(StatTotal)'   
	   //pvalues
	   local v = 1
	   foreach var in $balance_students2{
		 ereturn clear 
		 capture areg `var' T $sample, a(block) cluster(schoolid) //sample_simat==1 &
		 if _rc==0 matrix P3[`v',1] =2*(1-normal(abs(_b[T]/_se[T])))
		 local ++v
	   }

 //compilation
 matrix T2 = R2,P2[1...,1], N2
 matrix T3 = R3,P3[1...,1], N3
 
 matrix T=T2\T3
 mat list T
 drop _all
 svmat2 T, rnames(var) 

 insertrow, place(before) row(5)
 insertrow, place(before) row(1)

 gen Panel = "" 
 gen Variables=""
 order Panel Variables
 replace Panel = "Panel A:" in 1
 replace Panel = "Panel B:" in 6
  
 replace Variables="Avg. beg. G1 students' characteristics" if _n==1
 replace Variables="\hspace{2mm} Age" if _n==2
 replace Variables="\hspace{2mm} Female" if _n==3
 replace Variables="\hspace{2mm} No disability" if _n==4 
 replace Variables="\hspace{2mm} Low socio-econ status" if _n==5 

 replace Variables="Avg. end KG students' characteristics" if _n==6
 replace Variables="\hspace{2mm} Prob. response" if _n==7
 replace Variables="\hspace{2mm} Literacy" if _n==8
 replace Variables="\hspace{2mm} Motor" if _n==9
 replace Variables="\hspace{2mm} Socio-affective" if _n==10

 drop var
 
 insertrow, place(before) row(6)
 insertrow, place(before) row(1)
 
 foreach j in 1 2 3{
   gen aux = string(T`j', "%9.2f")
   replace aux = "" if aux=="."
   drop T`j'
   ren aux T`j'
 }
 
 foreach j in 4{
   gen aux = string(T`j', "%9.0f")
   replace aux = "" if aux=="."
   drop T`j'
   ren aux T`j'
 }
 order Panel Variables T1 T2 T3 T4 
 
 label var T1 "Treatment"
 label var T2 "Control"
 label var T3 "p-value of $H0:\beta_t=\beta_c$"
 label var T4 "Obs."
 
 #delimit ;
 global note "Note: Panel A shows the average beginning of first grade characteristics for the sample of students with availabe outcome at least in one follow-up time horizon. Panel B shows the average end of kindergarten characteristics for the sample of students with availabe outcome at least in one follow-up time horizon and the probability of response for these data. Literacy, motor and socio-affective characteristics are simple averages of indicator sub-itmes that compose each variable. We then standardized to the mean and standard deviation of the  control group. Columns labeled 'Treatment' show the average for students in schools randomized to treatment. Columns labeled 'Control' show the average for students in schools randomized to control. Column labeled 'p-value of $H0:\beta_t=\beta_c$' presents the p-value of the treatment indicator coefficient in a regression with each row variable as the outcome. All regressions include strata fixed effects and standard errors are clustered at the school level.";
 #delimit cr
 texsave using "$dir/results/Appendix_Table_Balance_SampleNoAttrition.tex", width(0.9\textwidth) frag ///
 replace size(scriptsize) align(llCCCC) location(ht) varlabels rowsep(1ex) ///
 title(Balance After Attrition) marker(tab:balance_afterattrition) ///
 footnote("$note", size(scriptsize)) nofix
  

 
 *******************************************************************************
 //APPENDIX TABLE 2
	/* We do not include this table because publishing the microdata on non-standardized scores could lead to violations of confidentiality of students, teachers or schools. We computed aggregate statistics fro control and treatment group and are available in file 'scorestabs.dta'. */

 
 *******************************************************************************
 //APPENDIX TABLE 3
	/*We do it in excel*/
